
set hive.exec.dynamic.partition=true; -- 动态分区
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions=500; -- 每天生成 60 个分区
set hive.exec.max.dynamic.partitions.pernode=500; -- 每天生成 60 个分区

insert overwrite table jms_dm.dm_end_dispatch_cheat_swip_sum_dt
select to_date(sign_time)         as sign_time
       ,dispatch_agent_code
       ,dispatch_agent_name
       ,sign_network_code
       ,sign_network_name
       ,sign_agent_code
       ,sign_agent_name
       ,receiver_mobile_phone
       ,mobile_phone_bf_trd
       ,mobile_phone_lst_fth
       ,count(waybill_no)         as disp_swip_cnt
       ,to_date(sign_time)     as dt 
  from jms_dm.dm_end_dispatch_cheat_swip_detail_dt 
 where dt = '{{ execution_date | cst_ds }}' 
 group by to_date(sign_time) 
        ,dispatch_agent_code
        ,dispatch_agent_name
        ,sign_network_code
        ,sign_network_name
        ,sign_agent_code
        ,sign_agent_name
        ,receiver_mobile_phone
        ,mobile_phone_bf_trd
        ,mobile_phone_lst_fth
distribute by pmod(hash(receiver_mobile_phone), 4)